#ifndef SM_TABLE_H
#define SM_TABLE_H

//错误码定义
#define SM4A_STATE_TRANSITION_BASE_ERROR (0x53540000)
#define SM4A_PRECONDITION_ERROR                (SM4A_STATE_TRANSITION_BASE_ERROR + 0x01)
#define SM4A_NULL_POINTER_ERROR                (SM4A_STATE_TRANSITION_BASE_ERROR + 0x02)
#define SM4A_STATE_MACHINE_NOT_CREATED_ERROR   (SM4A_STATE_TRANSITION_BASE_ERROR + 0x03)
#define SM4A_ST_PARAMETERS_ERROR               (SM4A_STATE_TRANSITION_BASE_ERROR + 0x04)
#define SM4A_QU_PARAMETERS_ERROR               (SM4A_STATE_TRANSITION_BASE_ERROR + 0x04)
#define SM4A_ST_SYSTEM_ERROR                   (SM4A_STATE_TRANSITION_BASE_ERROR + 0x05)

//状态枚举
typedef enum
{
    SM_STATE_MIN = -1,
    SM_STATE_ERROR = 0,
    SM_STATE_TERMINATED = 1,
    SM_STATE_IDLE = 2,
    SM_STATE_QUEUE_EMPTY = 3,
    SM_STATE_QUEUE_PARTY_FULL = 4,
    SM_STATE_QUEUE_FULL = 5,
    SM_STATE_MAX = 6
}SM_STATE_ENUM;

//事件枚举
typedef enum
{
    SM_EVENT_MIN = -1,
    SM_EVENT_INITIALIZE = 0,
    SM_EVENT_TERMINATE = 1,
    SM_EVENT_QUEUE = 2,
    SM_EVENT_QUEUE_FULL = 3,
    SM_EVENT_GET_RESULT = 4,
    SM_EVENT_GET_RESULT_EMPTY = 5,
    SM_EVENT_ERROR = 6,
    SM_EVENT_MAX = 7
}SM_EVENT_ENUM;

//队列状态枚举
typedef enum
{
    QUEUE_STATE_MIN = -1,
    QUEUE_STATE_EMPTY,
    QUEUE_STATE_PARTY_FULL,
    QUEUE_STATE_FULL,
    QUEUE_STATE_MAX
}SM_QUEUE_STATE_ENUM;


//定义状态机控制器结构
typedef struct
{
    SM_STATE_ENUM sm_current_state;
    int (*sm_transition_table_p)[SM_EVENT_MAX+1][SM_STATE_MAX+1];
    int (*sm_error_check_table_p)[SM_EVENT_MAX+1][SM_STATE_MAX+1];
} SM_STATE_MACHINE_STRUCT;


#endif // SM_TABLE_H
